﻿//�����Ǳ�����cdr�ļ�
package com.webbei.Backstage.action;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.util.Date;

import org.apache.struts2.ServletActionContext;

import com.webbei.Backstage.service.BackstateSer;
import com.webbei.util.Arithmetic;

public class DownloadCDR {
	private BackstateSer bao;
	private String fileName;
	private InputStream content;
	private String downloadFileName;
	private String contentTypeFileName;
	private String username;
	private String orderId;
	
	public String execute(){
		return "success";
	}
	public String getFileName() {
		return fileName;
	}
	public void setFileName(String fileName) {
		this.fileName = fileName;
	}
	public InputStream getContent() {
		System.out.println("orderId:"+orderId);
		String realPath=ServletActionContext.getServletContext().getRealPath("/");
		String path=Arithmetic.getDesString(fileName);
		String fileRealPath = realPath+path;
		System.out.println("fileRealPath:"+fileRealPath);
		File file=new File(fileRealPath);
		try {
			content=new FileInputStream(file);
			this.downloadFileName=orderId+path.substring(path.lastIndexOf("."),path.length());
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
		return content;
	}
	public void setContent(InputStream content) {
		this.content = content;
	}
	public String getDownloadFileName() {
		return downloadFileName;
	}
	public void setDownloadFileName(String downloadFileName) {
		this.downloadFileName = downloadFileName;
	}
   public String getUsername() {
		return username;
	}
	public void setUsername(String username) {
		this.username = username;
	}
	
	public BackstateSer getBao() {
		return bao;
	}
	public void setBao(BackstateSer bao) {
		this.bao = bao;
	}
	public String getOrderId() {
		return orderId;
	}
	public void setOrderId(String orderId) {
		this.orderId = orderId;
	}
	public String getContentTypeFileName() {
		return contentTypeFileName;
	}
	public void setContentTypeFileName(String contentTypeFileName) {
		this.contentTypeFileName = contentTypeFileName;
	}

}
